﻿namespace Forms
{
    using Forms.My;
    using Forms.My.Resources;

    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class frmAuswertung : Form
    {

        public string FilterBeschreibung;

        public int[] FilterID;

        public string FilterString;

        public bool ShowAutomated;

        public frmAuswertung()
        {
            base.Load += new EventHandler(this.frmAuswertung_Load);
            base.Leave += new EventHandler(this.frmAuswertung_Leave);
            base.Resize += new EventHandler(this.Form_Resize);
            
            this.FilterID = new int[0x65];
            this.InitializeComponent();

        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            this.DetachEventHandlers();
            base.OnFormClosing(e);
        }

        private void btnReload_Click(object sender, EventArgs e)
        {
            MyProject.Forms.Main.Reload();
        }

        /// <summary>
        /// Selektiert die Ablöse daten vor.
        /// </summary>
        private void CheckAbloesen()
        {
            this.ToolStripButtonAbloesen.Enabled = false;
            DataRow[] rowArray = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Select("FA_Abloesen = 1");
            if (rowArray.Length != 0)
            {
                foreach (DataRow row in rowArray)
                {
                    if (MyProject.Forms.Main.cs.Table_Auswertung.Select("FA_ID = '" + row["FA_ID"] + "'").Length != 0)
                    {
                        this.ToolStripButtonAbloesen.Enabled = true;
                        return;
                    }
                }
            }
        }

        private void cmbFilter_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.InitFilter();
            MyProject.Forms.Main.InitData(Main.TableType.Auswertung, this.cmbFilter.SelectedIndex);
        }

        private void cmbFilterNach_SelectedIndexChanged(object sender, EventArgs e)
        {
            MyProject.Forms.Main.InitData(Main.TableType.Auswertung, this.cmbFilter.SelectedIndex);
        }

        private void ContextMenuFA_Click(object sender, ToolStripItemClickedEventArgs e)
        {
            if (this.DataGridViewAuswertung.SelectedRows.Count > 0)
            {
                IEnumerator enumerator = this.DataGridViewAuswertung.SelectedRows.GetEnumerator();
                try
                {

                    while (enumerator.MoveNext())
                    {
                        DataGridViewRow current = (DataGridViewRow)enumerator.Current;
                        if (Conversions.ToString(e.ClickedItem.Tag) == "EASY")
                        {
                            if (this.DataGridViewAuswertung.SelectedRows.Count == 1)
                            {
                                string fileName =
                                    Conversions.ToString(
                                        Operators.ConcatenateObject(
                                            Operators.ConcatenateObject(
                                                (((((("http://" + MySettings.MySettingsProperty.EasyServerURL)
                                                     + "/jsp/qv?pri=" + MySettings.MySettingsProperty.EasyMandant)
                                                    + "&lg=" + MySettings.MySettingsProperty.EasyUsername) + "&pw="
                                                   + MySettings.MySettingsProperty.EasyPasswort) + "&ar="
                                                  + MySettings.MySettingsProperty.EasyArchiv)
                                                 +
                                                 Strings.Format(
                                                     Conversions.ToDate(current.Cells["RE_Dat_VK"].Value), "yyyy")
                                                 + "&q_") + MySettings.MySettingsProperty.EasyFeldname + "=",
                                                current.Cells["RE_Nr_Vk"].Value),
                                            "&_dlcViewMode=full"));
                                if (MySettings.MySettingsProperty.EasyExtern)
                                {
                                    Process.Start(fileName);
                                }
                                else
                                {
                                    this.EasyBrowser.ScriptErrorsSuppressed = true;
                                    this.EasyBrowser.Navigate(new Uri(fileName));
                                    this.EasyContainer.Panel2Collapsed = false;
                                }
                            }
                        }
                        else if (Operators.ConditionalCompareObjectEqual(e.ClickedItem.Tag, null, false))
                        {
                            current.Cells["FA_Col"].Value = DBNull.Value;
                            current.DefaultCellStyle.BackColor = this.DataGridViewAuswertung.DefaultCellStyle.BackColor;
                        }
                        else
                        {
                            current.Cells["FA_Col"].Value = RuntimeHelpers.GetObjectValue(e.ClickedItem.Tag);
                            DataRow[] rowArray =
                                MyProject.Forms.Main.cs.Table_Finanzierungsarten.Select(
                                    Conversions.ToString(
                                        Operators.ConcatenateObject(
                                            Operators.ConcatenateObject("FA_ID='", e.ClickedItem.Tag), "'")));
                            if (rowArray.Length > 0)
                            {
                                current.DefaultCellStyle.BackColor =
                                    Color.FromName(Conversions.ToString(rowArray[0]["FA_Color"]));
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
            this.DataGridViewAuswertung.CommitEdit(DataGridViewDataErrorContexts.Commit);
            this.InitSums();
            this.CheckAbloesen();
        }

        private void ContextMenuFA_Opening(object sender, CancelEventArgs e)
        {
            this.ContextMenuFA.Items.Clear();
            if (this.DataGridViewAuswertung.SelectedRows.Count > 0)
            {
                IEnumerator enumerator = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.GetEnumerator();
                this.ContextMenuFA.Items.Add("Finanzierungsart entfernen").Tag = null;
                ToolStripItem item = this.ContextMenuFA.Items.Add("-");
                try
                {

                    while (enumerator.MoveNext())
                    {
                        DataRow current = (DataRow)enumerator.Current;
                        item =
                            (ToolStripItem)
                            NewLateBinding.LateGet(
                                this.ContextMenuFA.Items,
                                null,
                                "Add",
                                new object[]
                                    {
                                        Operators.ConcatenateObject(
                                            Operators.ConcatenateObject(
                                                Operators.ConcatenateObject(
                                                    Operators.ConcatenateObject(
                                                        "in Finanzierungsart ", current["FA_KBz"]),
                                                    " - "),
                                                current["FA_Name"]),
                                            " ändern")
                                    },
                                null,
                                null,
                                null);
                        item.Tag = RuntimeHelpers.GetObjectValue(current["FA_ID"]);
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                if (MySettings.MySettingsProperty.EasyUsername != "")
                {
                    item = this.ContextMenuFA.Items.Add("-");
                    item = this.ContextMenuFA.Items.Add("Rechnung im Easy-Archiv suchen");
                    if (this.DataGridViewAuswertung.SelectedRows.Count == 1)
                    {
                        item.Enabled = true;
                        item.Tag = "EASY";
                    }
                    else
                    {
                        item.Enabled = false;
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }

        private void DataGridViewAuswertung_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            IEnumerator enumerator = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.GetEnumerator();
            ;
            this.DataGridViewAuswertung.Rows[e.RowIndex].DefaultCellStyle.BackColor =
                this.DataGridViewAuswertung.DefaultCellStyle.BackColor;
            try
            {

                while (enumerator.MoveNext())
                {
                    DataRow current = (DataRow)enumerator.Current;
                    if ((this.DataGridViewAuswertung["FA_Col", e.RowIndex].Value != DBNull.Value)
                        &&
                        Operators.ConditionalCompareObjectEqual(
                            this.DataGridViewAuswertung["FA_Col", e.RowIndex].Value, current["FA_ID"], false))
                    {
                        this.DataGridViewAuswertung.Rows[e.RowIndex].DefaultCellStyle.BackColor =
                            Color.FromName(Conversions.ToString(current["FA_Color"]));
                        goto Label_0108;
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
            Label_0108:
            this.DataGridViewAuswertung.CommitEdit(DataGridViewDataErrorContexts.Commit);
            this.InitSums();
            this.CheckAbloesen();
        }

        

        public void FilterChange(int FilterIndex)
        {
            string left = "";
            if (!this.ShowAutomated)
            {
                IEnumerator enumerator = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.GetEnumerator();
                left = left + " AND ( Isnull(FA_ID,-1) = -1";
                try
                {

                    while (enumerator.MoveNext())
                    {
                        DataRow current = (DataRow)enumerator.Current;
                        if (
                            Conversions.ToBoolean(
                                Operators.AndObject(
                                    Operators.CompareObjectEqual(current["FA_KundeAuto"], "", false),
                                    Operators.CompareObjectEqual(current["FA_Tage_Auto"], 0, false))))
                        {
                            left =
                                Conversions.ToString(
                                    Operators.ConcatenateObject(
                                        left,
                                        Operators.ConcatenateObject(
                                            Operators.ConcatenateObject(" OR FA_ID = '", current["FA_ID"]), "'")));
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
                left = left + " )";
            }
            DataView view = new DataView();
            view.Table = MyProject.Forms.Main.cs.Table_Auswertung;
            switch (FilterIndex)
            {
                case 0:
                    this.ResetFilter();
                    this.FilterString = "";
                    if (!this.ShowAutomated & (left != ""))
                    {
                        this.FilterString = left.Substring(5);
                        view.RowFilter = this.FilterString;
                    }
                    this.FilterBeschreibung = "alle Datensätze";
                    break;

                case 1:
                    if (this.cmbFilterNach.SelectedIndex > -1)
                    {
                        this.FilterString = "FA_ID='"
                                            + Conversions.ToString(this.FilterID[this.cmbFilterNach.SelectedIndex])
                                            + "'";
                        view.RowFilter = this.FilterString;
                    }
                    if (this.cmbFilterNach.SelectedIndex > -1)
                    {
                        DataRow[] rowArray =
                            MyProject.Forms.Main.cs.Table_Finanzierungsarten.Select(
                                "FA_ID='" + Conversions.ToString(this.FilterID[this.cmbFilterNach.SelectedIndex]) + "'");
                        if (rowArray.Length > 0)
                        {
                            this.FilterBeschreibung =
                                Conversions.ToString(
                                    Operators.ConcatenateObject("mit Finanzierungsart ", rowArray[0]["FA_Name"]));
                        }
                    }
                    else
                    {
                        this.FilterBeschreibung = "alle Datensätze";
                    }
                    break;

                case 2:
                    this.FilterString = "F1_Header_ID='"
                                        + Conversions.ToString(this.FilterID[this.cmbFilterNach.SelectedIndex]) + "'";
                    view.RowFilter = this.FilterString + left;
                    this.FilterBeschreibung =
                        Conversions.ToString(Operators.ConcatenateObject("von Datei ", this.cmbFilterNach.SelectedItem));
                    break;

                case 3:
                    this.FilterString = "BMW_Header_ID='"
                                        + Conversions.ToString(this.FilterID[this.cmbFilterNach.SelectedIndex]) + "'";
                    view.RowFilter = this.FilterString + left;
                    this.FilterBeschreibung =
                        Conversions.ToString(Operators.ConcatenateObject("von Datei ", this.cmbFilterNach.SelectedItem));
                    break;

                case 4:
                    {
                        string str2 = "Kunden_Nr LIKE '" + this.txtFilterNach.Text + "*'";
                        if (str2 == "Kunden_Nr LIKE '*'")
                        {
                            this.FilterString = "";
                            this.FilterBeschreibung = "alle Datensätze";
                            if (!this.ShowAutomated & (left != ""))
                            {
                                this.FilterString = left.Substring(5);
                                view.RowFilter = this.FilterString;
                            }
                            break;
                        }
                        this.FilterString = str2;
                        view.RowFilter = str2 + left;
                        this.FilterBeschreibung = "mit Kundennummer " + this.txtFilterNach.Text;
                        break;
                    }
            }
            if (!this.ShowAutomated)
            {
                this.FilterBeschreibung = this.FilterBeschreibung + " (keine automatisch zugewiesenen)";
            }
            if (FilterIndex > -1)
            {
                this.DataGridViewAuswertung.DataSource = view;
            }
            this.InitGridColors();
            this.InitSums();
        }

        private void FilterZurücksetzenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.ResetFilter();
        }

        private void Form_Resize(object sender, EventArgs e)
        {
        }

        private void frmAuswertung_Leave(object sender, EventArgs e)
        {
            MyProject.Forms.Main.StatusLabel.Text = "Speichere...";
            MyProject.Forms.Main.Refresh();
            MyProject.Forms.Main.cs.BemerkungenSpeichernAuswertung();
            MyProject.Forms.Main.StatusLabel.Text = "Bereit!";
        }

        private void frmAuswertung_Load(object sender, EventArgs e)
        {
            this.AssignEventHandler();
            this.InitFACombo();
            this.InitSums();
            this.CheckAbloesen();

            MyProject.Forms.Main.InitData(Main.TableType.Auswertung, this.cmbFilter.SelectedIndex);
        }

        private void Grid_Sorted(object sender, EventArgs e)
        {
            this.InitGridColors();
        }

        public void InitFACombo()
        {
            DataGridViewComboBoxColumn column2 =
                (DataGridViewComboBoxColumn)this.DataGridViewAuswertung.Columns["FA_Col"];
            column2.DisplayMember = "FA_KBz";
            column2.ValueMember = "FA_ID";
            column2.DataPropertyName = "FA_ID";
            column2.DataSource = MyProject.Forms.Main.cs.Table_Finanzierungsarten;
            column2 = null;
        }

        private void InitFilter()
        {
            switch (this.cmbFilter.SelectedIndex)
            {
                case 0:
                    this.ResetFilter();
                    break;

                case 1:
                    {
                        IEnumerator enumerator = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.GetEnumerator();
                        ;
                        ToolStripComboBox cmbFilterNach = this.cmbFilterNach;
                        cmbFilterNach.Items.Clear();
                        try
                        {

                            while (enumerator.MoveNext())
                            {
                                DataRow current = (DataRow)enumerator.Current;
                                int index = cmbFilterNach.Items.Add(RuntimeHelpers.GetObjectValue(current["FA_Kbz"]));
                                this.FilterID[index] = Conversions.ToInteger(current["FA_ID"]);
                            }
                        }
                        finally
                        {
                            if (enumerator is IDisposable)
                            {
                                (enumerator as IDisposable).Dispose();
                            }
                        }
                        if (cmbFilterNach.Items.Count > 0)
                        {
                            cmbFilterNach.SelectedIndex = 0;
                        }
                        else
                        {
                            cmbFilterNach.SelectedIndex = -1;
                        }
                        cmbFilterNach.Visible = true;
                        cmbFilterNach = null;
                        this.txtFilterNach.Text = "";
                        this.txtFilterNach.Visible = false;
                        break;
                    }
                case 2:
                    {
                        IEnumerator enumerator2 = MyProject.Forms.Main.cs.Table_F1Headers.Rows.GetEnumerator();
                        ToolStripComboBox box2 = this.cmbFilterNach;
                        box2.Items.Clear();
                        try
                        {

                            while (enumerator2.MoveNext())
                            {
                                DataRow row2 = (DataRow)enumerator2.Current;
                                int num2 = box2.Items.Add(Path.GetFileName(Conversions.ToString(row2["FileName"])));
                                this.FilterID[num2] = Conversions.ToInteger(row2["F1_Header_Id"]);
                            }
                        }
                        finally
                        {
                            if (enumerator2 is IDisposable)
                            {
                                (enumerator2 as IDisposable).Dispose();
                            }
                        }
                        if (box2.Items.Count > 0)
                        {
                            box2.SelectedIndex = 0;
                        }
                        else
                        {
                            box2.SelectedIndex = -1;
                        }
                        box2.Visible = true;
                        box2 = null;
                        this.txtFilterNach.Text = "";
                        this.txtFilterNach.Visible = false;
                        break;
                    }
                case 3:
                    {
                        IEnumerator enumerator3 = MyProject.Forms.Main.cs.Table_BMWBankHeaders.Rows.GetEnumerator();
                        ToolStripComboBox box3 = this.cmbFilterNach;
                        box3.Items.Clear();
                        try
                        {

                            while (enumerator3.MoveNext())
                            {
                                DataRow row3 = (DataRow)enumerator3.Current;
                                int num3 = box3.Items.Add(RuntimeHelpers.GetObjectValue(row3["Name"]));
                                this.FilterID[num3] = Conversions.ToInteger(row3["BMW_Header_Id"]);
                            }
                        }
                        finally
                        {
                            if (enumerator3 is IDisposable)
                            {
                                (enumerator3 as IDisposable).Dispose();
                            }
                        }
                        if (box3.Items.Count > 0)
                        {
                            box3.SelectedIndex = 0;
                        }
                        else
                        {
                            box3.SelectedIndex = -1;
                        }
                        box3.Visible = true;
                        box3 = null;
                        this.txtFilterNach.Text = "";
                        this.txtFilterNach.Visible = false;
                        break;
                    }
                case 4:
                    this.cmbFilterNach.Visible = false;
                    this.txtFilterNach.Visible = true;
                    this.txtFilterNach.Text = "";
                    this.txtFilterNach.Enabled = true;
                    break;
            }
            this.InitSums();
        }

        public void InitGridColors()
        {
            IEnumerator enumerator = ((IEnumerable)this.DataGridViewAuswertung.Rows).GetEnumerator();
            try
            {

                while (enumerator.MoveNext())
                {
                    IEnumerator enumerator2 = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.GetEnumerator();
                    DataGridViewRow current = (DataGridViewRow)enumerator.Current;
                    current.DefaultCellStyle.BackColor = this.DataGridViewAuswertung.DefaultCellStyle.BackColor;
                    try
                    {

                        while (enumerator2.MoveNext())
                        {
                            DataRow row2 = (DataRow)enumerator2.Current;
                            if ((current.Cells["FA_Col"].Value != DBNull.Value)
                                &&
                                Operators.ConditionalCompareObjectEqual(
                                    current.Cells["FA_Col"].Value, row2["FA_ID"], false))
                            {
                                current.DefaultCellStyle.BackColor =
                                    Color.FromName(Conversions.ToString(row2["FA_Color"]));
                                break;
                            }
                        }
                        continue;
                    }
                    finally
                    {
                        if (enumerator2 is IDisposable)
                        {
                            (enumerator2 as IDisposable).Dispose();
                        }
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            DataGridViewCellStyle style4 = new DataGridViewCellStyle();
            DataGridViewCellStyle style5 = new DataGridViewCellStyle();
            DataGridViewCellStyle style2 = new DataGridViewCellStyle();
            DataGridViewCellStyle style3 = new DataGridViewCellStyle();
            this.DataGridViewAuswertung = new DataGridView();
            this.ContextMenuFA = new ContextMenuStrip();
            this.TABAuswertungBindingSource = new BindingSource();
            this.DatenschemaBMW = new DatenschemaBMW();
            this.ToolStrip1 = new ToolStrip();
            this.btnReload = new ToolStripButton();
            this.ToolStripSeparator2 = new ToolStripSeparator();
            this.ToolStripButton1 = new ToolStripButton();
            this.ToolStripButtonAbloesen = new ToolStripButton();
            this.ToolStripSeparator1 = new ToolStripSeparator();
            this.butFilter = new ToolStripSplitButton();
            this.FilterZurücksetzenToolStripMenuItem = new ToolStripMenuItem();
            this.ToolStripButton2 = new ToolStripButton();
            this.cmbFilter = new ToolStripComboBox();
            this.cmbFilterNach = new ToolStripComboBox();
            this.txtFilterNach = new ToolStripTextBox();
            this.ListViewSum = new ListView();
            this.col1 = new ColumnHeader();
            this.col2 = new ColumnHeader();
            this.SplitContainer1 = new SplitContainer();
            this.EasyContainer = new SplitContainer();
            this.EasyBrowser = new WebBrowser();
            //this.ContextMenuEB = new ContextMenuStrip(this.components);
            this.MenuItemClose = new ToolStripMenuItem();
            this.TABFinanzArtenBindingSource = new BindingSource();
            this.FA_Col = new DataGridViewComboBoxColumn();
            this.Kredit_Saldo = new DataGridViewTextBoxColumn();
            this.FGSTNrDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
            this.Name1DataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
            this.RE_Dat_VK = new DataGridViewTextBoxColumn();
            this.RE_Nr_Vk = new DataGridViewTextBoxColumn();
            this.KundenNrDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
            this.KreditNrDataGridViewTextBoxColumn = new DataGridViewTextBoxColumn();
            this.Bemerkung = new DataGridViewTextBoxColumn();
            this.FA_ID = new DataGridViewTextBoxColumn();
            ((ISupportInitialize)this.DataGridViewAuswertung).BeginInit();
            ((ISupportInitialize)this.TABAuswertungBindingSource).BeginInit();
            this.DatenschemaBMW.BeginInit();
            this.ToolStrip1.SuspendLayout();
            this.SplitContainer1.Panel1.SuspendLayout();
            this.SplitContainer1.Panel2.SuspendLayout();
            this.SplitContainer1.SuspendLayout();
            this.EasyContainer.Panel1.SuspendLayout();
            this.EasyContainer.Panel2.SuspendLayout();
            this.EasyContainer.SuspendLayout();
            //this.ContextMenuEB.SuspendLayout();
            ((ISupportInitialize)this.TABFinanzArtenBindingSource).BeginInit();
            this.SuspendLayout();
            this.DataGridViewAuswertung.AllowUserToAddRows = false;
            this.DataGridViewAuswertung.AllowUserToDeleteRows = false;
            this.DataGridViewAuswertung.AllowUserToOrderColumns = true;
            this.DataGridViewAuswertung.AllowUserToResizeRows = false;
            this.DataGridViewAuswertung.AutoGenerateColumns = false;
            this.DataGridViewAuswertung.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
            style.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style.BackColor = SystemColors.Control;
            style.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            style.ForeColor = SystemColors.WindowText;
            style.SelectionBackColor = SystemColors.Highlight;
            style.SelectionForeColor = SystemColors.HighlightText;
            style.WrapMode = DataGridViewTriState.True;
            this.DataGridViewAuswertung.ColumnHeadersDefaultCellStyle = style;
            this.DataGridViewAuswertung.Columns.AddRange(
                new DataGridViewColumn[]
                    {
                        this.FA_Col, this.Kredit_Saldo, this.FGSTNrDataGridViewTextBoxColumn,
                        this.Name1DataGridViewTextBoxColumn, this.RE_Dat_VK, this.RE_Nr_Vk,
                        this.KundenNrDataGridViewTextBoxColumn, this.KreditNrDataGridViewTextBoxColumn, this.Bemerkung,
                        this.FA_ID
                    });
            this.DataGridViewAuswertung.ContextMenuStrip = this.ContextMenuFA;
            this.DataGridViewAuswertung.DataSource = this.TABAuswertungBindingSource;
            style4.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style4.BackColor = SystemColors.Window;
            style4.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            style4.ForeColor = SystemColors.ControlText;
            style4.SelectionBackColor = SystemColors.Highlight;
            style4.SelectionForeColor = SystemColors.HighlightText;
            style4.WrapMode = DataGridViewTriState.False;
            this.DataGridViewAuswertung.DefaultCellStyle = style4;
            this.DataGridViewAuswertung.Dock = DockStyle.Fill;
            this.DataGridViewAuswertung.Location = new Point(0, 0);
            this.DataGridViewAuswertung.Name = "DataGridViewAuswertung";
            style5.Alignment = DataGridViewContentAlignment.MiddleLeft;
            style5.BackColor = SystemColors.Control;
            style5.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
            style5.ForeColor = SystemColors.WindowText;
            style5.SelectionBackColor = SystemColors.Highlight;
            style5.SelectionForeColor = SystemColors.HighlightText;
            style5.WrapMode = DataGridViewTriState.True;
            this.DataGridViewAuswertung.RowHeadersDefaultCellStyle = style5;
            this.DataGridViewAuswertung.RowHeadersVisible = false;
            this.DataGridViewAuswertung.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            this.DataGridViewAuswertung.ShowCellToolTips = false;

            this.DataGridViewAuswertung.Size = new Size(0x335, 0x1cd);
            this.DataGridViewAuswertung.TabIndex = 0;
            this.ContextMenuFA.Name = "ContextMenuFA";
            this.ContextMenuFA.Size = new Size(0x3d, 4);
            this.TABAuswertungBindingSource.DataMember = "TAB_Auswertung";
            this.TABAuswertungBindingSource.DataSource = this.DatenschemaBMW;
            this.DatenschemaBMW.DataSetName = "DatenschemaBMW";
            this.DatenschemaBMW.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
            this.ToolStrip1.Items.AddRange(
                new ToolStripItem[]
                    {
                        this.btnReload, this.ToolStripSeparator2, this.ToolStripButton1, this.ToolStripButtonAbloesen,
                        this.ToolStripSeparator1, this.butFilter, this.ToolStripButton2, this.cmbFilter,
                        this.cmbFilterNach, this.txtFilterNach
                    });
            this.ToolStrip1.Location = new Point(0, 0);
            this.ToolStrip1.Name = "ToolStrip1";

            this.ToolStrip1.Size = new Size(0x335, 0x19);
            this.ToolStrip1.TabIndex = 1;
            this.ToolStrip1.Text = "ToolStrip1";
            this.btnReload.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.btnReload.Image = Resources.RepeatHS;
            this.btnReload.ImageTransparentColor = Color.Magenta;
            this.btnReload.Name = "btnReload";
            
            this.btnReload.Size = new Size(0x17, 0x16);
            this.btnReload.Text = "ToolStripButton3";
            this.btnReload.ToolTipText = "Auswertung wiederholen";
            this.ToolStripSeparator2.Name = "ToolStripSeparator2";
            
            this.ToolStripSeparator2.Size = new Size(6, 0x19);
            this.ToolStripButton1.Image = Resources.Symbol_Print;
            this.ToolStripButton1.ImageTransparentColor = Color.Magenta;
            this.ToolStripButton1.Name = "ToolStripButton1";
            
            this.ToolStripButton1.Size = new Size(0x44, 0x16);
            this.ToolStripButton1.Text = "Drucken";
            this.ToolStripButtonAbloesen.Image = Resources.Symbol_Abloesen;
            this.ToolStripButtonAbloesen.ImageTransparentColor = Color.Magenta;
            this.ToolStripButtonAbloesen.Name = "ToolStripButtonAbloesen";
            
            this.ToolStripButtonAbloesen.Size = new Size(0x41, 0x16);
            this.ToolStripButtonAbloesen.Text = "Ablösen";
            this.ToolStripSeparator1.Name = "ToolStripSeparator1";
            
            this.ToolStripSeparator1.Size = new Size(6, 0x19);
            this.butFilter.DropDownItems.AddRange(new ToolStripItem[] { this.FilterZurücksetzenToolStripMenuItem });
            this.butFilter.Image = Resources.Symbol_Filter;
            this.butFilter.ImageAlign = ContentAlignment.BottomCenter;
            this.butFilter.ImageTransparentColor = Color.Magenta;
            this.butFilter.Name = "butFilter";
            
            this.butFilter.Size = new Size(0x3d, 0x16);
            this.butFilter.Text = "Filter";
            this.butFilter.TextAlign = ContentAlignment.BottomRight;
            this.FilterZurücksetzenToolStripMenuItem.Name = "FilterZurücksetzenToolStripMenuItem";
            
            this.FilterZurücksetzenToolStripMenuItem.Size = new Size(0xa2, 0x16);
            this.FilterZurücksetzenToolStripMenuItem.Text = "Filter zurücksetzen";
            this.ToolStripButton2.DisplayStyle = ToolStripItemDisplayStyle.Image;
            this.ToolStripButton2.Image = Resources.Symbol_Zahnrad_Disabled;
            this.ToolStripButton2.ImageTransparentColor = Color.Magenta;
            this.ToolStripButton2.Name = "ToolStripButton2";
            
            this.ToolStripButton2.Size = new Size(0x17, 0x16);
            this.ToolStripButton2.Text = "ToolStripButton2";
            this.ToolStripButton2.ToolTipText = "Automatisch zugewiesene Finanzierungsarten ein/ausblenden";
            this.cmbFilter.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cmbFilter.FlatStyle = FlatStyle.Standard;
            this.cmbFilter.Items.AddRange(
                new object[]
                    { "kein", "nach Finanzierungsart", "nach Formel1-Datei", "nach BMW-Konto-Datei", "nach Kunden-Nr." });
            this.cmbFilter.Name = "cmbFilter";
            
            this.cmbFilter.Size = new Size(160, 0x19);
            this.cmbFilterNach.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cmbFilterNach.FlatStyle = FlatStyle.Standard;
            this.cmbFilterNach.Name = "cmbFilterNach";
            
            this.cmbFilterNach.Size = new Size(130, 0x19);
            this.txtFilterNach.BorderStyle = BorderStyle.FixedSingle;
            this.txtFilterNach.Name = "txtFilterNach";
           
            this.txtFilterNach.Size = new Size(130, 0x19);
            this.ListViewSum.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.ListViewSum.Columns.AddRange(new ColumnHeader[] { this.col1, this.col2 });
            this.ListViewSum.HeaderStyle = ColumnHeaderStyle.None;
            
            this.ListViewSum.Location = new Point(0, 2);
            this.ListViewSum.MultiSelect = false;
            this.ListViewSum.Name = "ListViewSum";
            
            this.ListViewSum.Size = new Size(370, 0x60);
            this.ListViewSum.TabIndex = 2;
            this.ListViewSum.UseCompatibleStateImageBehavior = false;
            this.ListViewSum.View = View.Details;
            this.col1.Text = "";
            this.col1.Width = 0xaf;
            this.col2.Text = "Summe";
            this.col2.TextAlign = HorizontalAlignment.Right;
            this.col2.Width = 170;
            this.SplitContainer1.Dock = DockStyle.Fill;
            
            this.SplitContainer1.Location =  new Point(0, 0x19);
            this.SplitContainer1.Name = "SplitContainer1";
            this.SplitContainer1.Orientation = Orientation.Horizontal;
            this.SplitContainer1.Panel1.Controls.Add(this.ListViewSum);
            this.SplitContainer1.Panel2.Controls.Add(this.EasyContainer);
            
            this.SplitContainer1.Size = new Size(0x335, 0x235);
            this.SplitContainer1.SplitterDistance = 100;
            this.SplitContainer1.TabIndex = 3;
            this.EasyContainer.Dock = DockStyle.Fill;
            
            this.EasyContainer.Location =new Point(0, 0);
            this.EasyContainer.Name = "EasyContainer";
            this.EasyContainer.Orientation = Orientation.Horizontal;
            this.EasyContainer.Panel1.Controls.Add(this.DataGridViewAuswertung);
            this.EasyContainer.Panel2.Controls.Add(this.EasyBrowser);
            this.EasyContainer.Panel2Collapsed = true;
            
            this.EasyContainer.Size = new Size(0x335, 0x1cd);
            this.EasyContainer.SplitterDistance = 0xd5;
            this.EasyContainer.TabIndex = 1;
            //this.EasyBrowser.ContextMenuStrip = this.ContextMenuEB;
            this.EasyBrowser.Dock = DockStyle.Fill;
            this.EasyBrowser.IsWebBrowserContextMenuEnabled = false;
            
            this.EasyBrowser.Location = new Point(0, 0);
            
            this.EasyBrowser.MinimumSize = new Size(20, 20);
            this.EasyBrowser.Name = "EasyBrowser";
            
            this.EasyBrowser.Size = new Size(150, 0x2e);
            this.EasyBrowser.TabIndex = 0;
            //this.ContextMenuEB.Items.AddRange(new ToolStripItem[] { this.MenuItemClose });
            //this.ContextMenuEB.Name = "ContextMenuEB";
            
            //this.ContextMenuEB.Size = new Size(0x7a, 0x1a);
            this.MenuItemClose.Name = "MenuItemClose";

            this.MenuItemClose.Size = new Size(0x79, 0x16);
            this.MenuItemClose.Text = "Schließen";
            this.TABFinanzArtenBindingSource.DataMember = "TAB_FinanzArten";
            this.TABFinanzArtenBindingSource.DataSource = this.DatenschemaBMW;
            this.FA_Col.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;
            this.FA_Col.FlatStyle = FlatStyle.Popup;
            this.FA_Col.HeaderText = "Finanzierungsart";
            this.FA_Col.Name = "FA_Col";
            this.FA_Col.Resizable = DataGridViewTriState.True;
            this.FA_Col.SortMode = DataGridViewColumnSortMode.Automatic;
            this.FA_Col.Width = 90;
            this.Kredit_Saldo.DataPropertyName = "Kredit_Saldo";
            style2.Alignment = DataGridViewContentAlignment.MiddleRight;
            style2.Format = "###,###,##0.00";
            this.Kredit_Saldo.DefaultCellStyle = style2;
            this.Kredit_Saldo.HeaderText = "Kredit Saldo";
            this.Kredit_Saldo.Name = "Kredit_Saldo";
            this.Kredit_Saldo.ReadOnly = true;
            this.FGSTNrDataGridViewTextBoxColumn.DataPropertyName = "FGST_Nr";
            this.FGSTNrDataGridViewTextBoxColumn.HeaderText = "Fahrgestell-Nr.";
            this.FGSTNrDataGridViewTextBoxColumn.Name = "FGSTNrDataGridViewTextBoxColumn";
            this.FGSTNrDataGridViewTextBoxColumn.ReadOnly = true;
            this.FGSTNrDataGridViewTextBoxColumn.Width = 90;
            this.Name1DataGridViewTextBoxColumn.DataPropertyName = "Name1";
            this.Name1DataGridViewTextBoxColumn.HeaderText = "Name";
            this.Name1DataGridViewTextBoxColumn.Name = "Name1DataGridViewTextBoxColumn";
            this.Name1DataGridViewTextBoxColumn.ReadOnly = true;
            this.Name1DataGridViewTextBoxColumn.Width = 150;
            this.RE_Dat_VK.DataPropertyName = "RE_Dat_VK";
            style3.Format = "dd.MM.yyyy";
            style3.NullValue = null;
            this.RE_Dat_VK.DefaultCellStyle = style3;
            this.RE_Dat_VK.HeaderText = "Rechnungsdatum VK";
            this.RE_Dat_VK.Name = "RE_Dat_VK";
            this.RE_Dat_VK.ReadOnly = true;
            this.RE_Dat_VK.Width = 0x85;
            this.RE_Nr_Vk.DataPropertyName = "RE_Nr_Vk";
            this.RE_Nr_Vk.HeaderText = "Rechnungs-Nr. VK";
            this.RE_Nr_Vk.Name = "RE_Nr_Vk";
            this.RE_Nr_Vk.ReadOnly = true;
            this.RE_Nr_Vk.Width = 0x79;
            this.KundenNrDataGridViewTextBoxColumn.DataPropertyName = "Kunden_Nr";
            this.KundenNrDataGridViewTextBoxColumn.HeaderText = "Kunden-Nr. (gek)";
            this.KundenNrDataGridViewTextBoxColumn.Name = "KundenNrDataGridViewTextBoxColumn";
            this.KundenNrDataGridViewTextBoxColumn.ReadOnly = true;
            this.KreditNrDataGridViewTextBoxColumn.DataPropertyName = "Kredit_Nr";
            this.KreditNrDataGridViewTextBoxColumn.HeaderText = "Kredit-Nr.";
            this.KreditNrDataGridViewTextBoxColumn.Name = "KreditNrDataGridViewTextBoxColumn";
            this.KreditNrDataGridViewTextBoxColumn.ReadOnly = true;
            this.KreditNrDataGridViewTextBoxColumn.Width = 0x4c;
            this.Bemerkung.DataPropertyName = "Bemerkung";
            this.Bemerkung.HeaderText = "Bemerkung";
            this.Bemerkung.Name = "Bemerkung";
            this.Bemerkung.Width = 250;
            this.FA_ID.DataPropertyName = "FA_ID";
            this.FA_ID.HeaderText = "FA_ID";
            this.FA_ID.Name = "FA_ID";
            this.FA_ID.Visible = false;

            this.AutoScaleDimensions = new SizeF(6f, 13f);
            this.ClientSize = new Size(0x335, 590);
            this.Controls.Add(this.SplitContainer1);
            this.Controls.Add(this.ToolStrip1);
            this.Name = "frmAuswertung";
            this.Text = "frmAuswertung";
            ((ISupportInitialize)this.DataGridViewAuswertung).EndInit();
            ((ISupportInitialize)this.TABAuswertungBindingSource).EndInit();
            this.DatenschemaBMW.EndInit();
            this.ToolStrip1.ResumeLayout(false);
            this.ToolStrip1.PerformLayout();
            this.SplitContainer1.Panel1.ResumeLayout(false);
            this.SplitContainer1.Panel2.ResumeLayout(false);
            this.SplitContainer1.ResumeLayout(false);
            this.EasyContainer.Panel1.ResumeLayout(false);
            this.EasyContainer.Panel2.ResumeLayout(false);
            this.EasyContainer.ResumeLayout(false);
            //this.ContextMenuEB.ResumeLayout(false);
            ((ISupportInitialize)this.TABFinanzArtenBindingSource).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        public void InitSums()
        {

            this.ListViewSum.Items.Clear();
            MyProject.Forms.Main.cs.Table_Auswertung.AcceptChanges();
            this.InitGridColors();
            ListViewItem item = this.ListViewSum.Items.Add("Gesamtsumme ungefiltert");
            item.BackColor = this.ListViewSum.BackColor;
            item.Font = new Font(item.Font, item.Font.Style | FontStyle.Bold);
            object objectValue =
                RuntimeHelpers.GetObjectValue(MyProject.Forms.Main.cs.Table_Auswertung.Compute("Sum(Kredit_Saldo)", ""));
            if (objectValue != DBNull.Value)
            {
                item.SubItems.Add(Strings.Format(RuntimeHelpers.GetObjectValue(objectValue), "###,###,##0.00"));
            }
            item = this.ListViewSum.Items.Add("Gesamtsumme gefiltert");
            item.BackColor = this.ListViewSum.BackColor;
            item.Font = new Font(item.Font, item.Font.Style | FontStyle.Bold);
            object obj3 =
                RuntimeHelpers.GetObjectValue(
                    MyProject.Forms.Main.cs.Table_Auswertung.Compute("Sum(Kredit_Saldo)", this.FilterString));
            if (obj3 != DBNull.Value)
            {
                item.SubItems.Add(Strings.Format(RuntimeHelpers.GetObjectValue(obj3), "###,###,##0.00"));
            }

            IEnumerator enumerator = MyProject.Forms.Main.cs.Table_Finanzierungsarten.Rows.GetEnumerator();
            try
            {

                while (enumerator.MoveNext())
                {
                    string str;
                    DataRow current = (DataRow)enumerator.Current;
                    item =
                        (ListViewItem)
                        NewLateBinding.LateGet(
                            this.ListViewSum.Items,
                            null,
                            "Add",
                            new object[] { "Summe " +  current["FA_KBz"] +  " - "  + current["FA_Name"]},
                            null,
                            null,
                            null);
                    item.BackColor = Color.FromName(Conversions.ToString(current["FA_Color"]));
                    item.Font = new Font(item.Font, item.Font.Style | FontStyle.Bold);
                    if (this.FilterString == "")
                    {
                        str = "FA_ID = '" + current["FA_ID"]+  "'";
                    }
                    else
                    {
                        str = "FA_ID = '" + current["FA_ID"] + "' AND (" + this.FilterString +")";
                    }
                    object obj2 =
                        RuntimeHelpers.GetObjectValue(
                            MyProject.Forms.Main.cs.Table_Auswertung.Compute("Sum(Kredit_Saldo)", str));
                    if (obj2 != DBNull.Value)
                    {
                        item.SubItems.Add(Strings.Format(RuntimeHelpers.GetObjectValue(obj2), "###,###,##0.00"));
                    }
                }
            }
            finally
            {
                if (enumerator is IDisposable)
                {
                    (enumerator as IDisposable).Dispose();
                }
            }
        }

        private void MenuItemClose_Click(object sender, EventArgs e)
        {
            this.EasyContainer.Panel2Collapsed = true;
        }

        public void ResetFilter()
        {
            this.cmbFilter.SelectedIndex = 0;
            this.cmbFilterNach.SelectedIndex = -1;
            this.txtFilterNach.Text = "";
            this.cmbFilterNach.Visible = false;
            this.txtFilterNach.Visible = true;
            this.txtFilterNach.Enabled = false;
            this.FilterString = "";
            this.InitSums();
        }

        private void ToolStripButton1_Click(object sender, EventArgs e)
        {
            MyProject.Forms.frmDruck.ShowDialog();
        }

        private void ToolStripButton2_Click(object sender, EventArgs e)
        {
            if (this.ShowAutomated)
            {
                this.ShowAutomated = false;
                this.ToolStripButton2.Image = Resources.Symbol_Zahnrad_Disabled;
            }
            else
            {
                this.ShowAutomated = true;
                this.ToolStripButton2.Image = Resources.Symbol_Zahnrad;
            }
            MyProject.Forms.Main.InitData(Main.TableType.Auswertung, this.cmbFilter.SelectedIndex);
        }

        private void ToolStripButtonAbloesen_Click(object sender, EventArgs e)
        {
            MyProject.Forms.frmAbloesen.ShowDialog();
        }

        private void txtFilterNach_TextChanged(object sender, EventArgs e)
        {
            MyProject.Forms.Main.InitData(Main.TableType.Auswertung, this.cmbFilter.SelectedIndex);
        }

        private DataGridViewTextBoxColumn Bemerkung;

        private ToolStripButton btnReload;

        private ToolStripSplitButton butFilter;

        public ToolStripComboBox cmbFilter;

        private ToolStripComboBox cmbFilterNach;



        private ColumnHeader col1;

        private ColumnHeader col2;

        //private ContextMenuStrip ContextMenuEB;

        private ContextMenuStrip ContextMenuFA;

        public DataGridView DataGridViewAuswertung;

        private DatenschemaBMW DatenschemaBMW;

        private WebBrowser EasyBrowser;

        private SplitContainer EasyContainer;

        private DataGridViewComboBoxColumn FA_Col;

        private DataGridViewTextBoxColumn FA_ID;

        private DataGridViewTextBoxColumn FGSTNrDataGridViewTextBoxColumn;

        private ToolStripMenuItem FilterZurücksetzenToolStripMenuItem;




        private DataGridViewTextBoxColumn Kredit_Saldo;

        private DataGridViewTextBoxColumn KreditNrDataGridViewTextBoxColumn;

        private DataGridViewTextBoxColumn KundenNrDataGridViewTextBoxColumn;

        private ListView ListViewSum;

        private ToolStripMenuItem MenuItemClose;




        private DataGridViewTextBoxColumn Name1DataGridViewTextBoxColumn;

        private DataGridViewTextBoxColumn RE_Dat_VK;

        private DataGridViewTextBoxColumn RE_Nr_Vk;

        private SplitContainer SplitContainer1;

        private BindingSource TABAuswertungBindingSource;

        public BindingSource TABFinanzArtenBindingSource;

        private ToolStrip ToolStrip1;

        private ToolStripButton ToolStripButton1;

        private ToolStripButton ToolStripButton2;

        private ToolStripButton ToolStripButtonAbloesen;


        private ToolStripSeparator ToolStripSeparator1;

        private ToolStripSeparator ToolStripSeparator2;

        private ToolStripTextBox txtFilterNach;

        private void AssignEventHandler()
        {
            this.ToolStripButton1.Click += ToolStripButton1_Click;
            this.FilterZurücksetzenToolStripMenuItem.Click += FilterZurücksetzenToolStripMenuItem_Click;
            this.DataGridViewAuswertung.Sorted += this.Grid_Sorted;
            this.DataGridViewAuswertung.CellEndEdit += DataGridViewAuswertung_CellEndEdit;
            this.cmbFilterNach.SelectedIndexChanged += cmbFilterNach_SelectedIndexChanged;
            this.ContextMenuFA.ItemClicked += ContextMenuFA_Click;
            this.ContextMenuFA.Opening += ContextMenuFA_Opening;
            this.btnReload.Click += this.btnReload_Click;
            this.cmbFilter.SelectedIndexChanged += cmbFilter_SelectedIndexChanged;
            this.MenuItemClose.Click += MenuItemClose_Click;
            this.ToolStripButton2.Click += ToolStripButton2_Click;
            this.ToolStripButtonAbloesen.Click += ToolStripButtonAbloesen_Click;
            this.txtFilterNach.TextChanged += txtFilterNach_TextChanged;

        }

        private void DetachEventHandlers()
        {
            if (this.ToolStripButton1 != null)
            {
                this.ToolStripButton1.Click -= ToolStripButton1_Click;
            }

            if (this.FilterZurücksetzenToolStripMenuItem != null)
            {
                this.FilterZurücksetzenToolStripMenuItem.Click -= FilterZurücksetzenToolStripMenuItem_Click;
            }


            if (this.DataGridViewAuswertung != null)
            {
                this.DataGridViewAuswertung.Sorted -= Grid_Sorted;
                this.DataGridViewAuswertung.CellEndEdit -= DataGridViewAuswertung_CellEndEdit;
            }


            if (this.ContextMenuFA != null)
            {
                this.ContextMenuFA.ItemClicked -= ContextMenuFA_Click;
                this.ContextMenuFA.Opening -= ContextMenuFA_Opening;
            }

            if (this.cmbFilterNach != null)
            {
                this.cmbFilterNach.SelectedIndexChanged -= cmbFilterNach_SelectedIndexChanged;
            }

            if (this.btnReload != null)
            {
                this.btnReload.Click -= this.btnReload_Click;
            }

            if (this.cmbFilter != null)
            {
                this.cmbFilter.SelectedIndexChanged -= cmbFilter_SelectedIndexChanged;
            }

            if (this.MenuItemClose != null)
            {
                this.MenuItemClose.Click -= MenuItemClose_Click;
            }



            if (this.ToolStripButton2 != null)
            {
                this.ToolStripButton2.Click -= ToolStripButton2_Click;
            }

            if (this.ToolStripButtonAbloesen != null)
            {
                this.ToolStripButtonAbloesen.Click -= ToolStripButtonAbloesen_Click;
            }
            if (this.txtFilterNach != null)
            {
                this.txtFilterNach.TextChanged -= txtFilterNach_TextChanged;
            }
        }



    }
}

